import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProfitReportSubAsinVO, ProfitReportSubAsinForm, ProfitReportSubAsinQuery } from '@/api/lingxing/profitReportSubAsin/types';
import { ProfitReportParentAsinQuery } from '@/api/lingxing/profitReportParentAsin/types';

/**
 * 查询领星利润报告-子ASIN列表
 * @param query
 * @returns {*}
 */

export const listProfitReportSubAsin = (query?: ProfitReportSubAsinQuery): AxiosPromise<ProfitReportSubAsinVO[]> => {
  return request({
    url: '/lingxing/profitReportSubAsin/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询领星利润报告-子ASIN详细
 * @param id
 */
export const getProfitReportSubAsin = (id: string | number): AxiosPromise<ProfitReportSubAsinVO> => {
  return request({
    url: '/lingxing/profitReportSubAsin/' + id,
    method: 'get'
  });
};

/**
 * 新增领星利润报告-子ASIN
 * @param data
 */
export const addProfitReportSubAsin = (data: ProfitReportSubAsinForm) => {
  return request({
    url: '/lingxing/profitReportSubAsin',
    method: 'post',
    data: data
  });
};

/**
 * 修改领星利润报告-子ASIN
 * @param data
 */
export const updateProfitReportSubAsin = (data: ProfitReportSubAsinForm) => {
  return request({
    url: '/lingxing/profitReportSubAsin',
    method: 'put',
    data: data
  });
};

/**
 * 删除领星利润报告-子ASIN
 * @param id
 */
export const delProfitReportSubAsin = (id: string | number | Array<string | number>) => {
  return request({
    url: '/lingxing/profitReportSubAsin/' + id,
    method: 'delete'
  });
};

export const syncData = (data?: ProfitReportSubAsinQuery) => {
  return request({
    url: '/lingxing/profitReportSubAsin/syncData',
    method: 'post',
    data: data
  });
};

export const getNewestUpdateTime = () => {
  return request({
    url: '/lingxing/profitReportSubAsin/getNewestUpdateTime',
    method: 'get'
  });
};
